package com.zkt.weichat.redis;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @program jc-club
* @author 赵开泰
* @date 2025/3/22 22:56
* @description 序列化相关配置类
**/

@Configuration
public class JacksonConfig {
	@Bean
	public ObjectMapper objectMapper() {
		ObjectMapper objectMapper = new ObjectMapper();
		
		// 注册 JavaTimeModule 支持 LocalDateTime 序列化[1,7](@ref)
		objectMapper.registerModule(new JavaTimeModule());
		// 禁用日期序列化为时间戳格式（转为 ISO 字符串）
		objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
		
		return objectMapper;
	}
}